package me.zhengjie.modules.system.rest.machine;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import me.zhengjie.annotation.Log;
import me.zhengjie.annotation.rest.AnonymousPostMapping;
import me.zhengjie.modules.system.domain.req.BankCardReqDTO;
import me.zhengjie.modules.system.domain.req.BankCardSubBranchReqDTO;
import me.zhengjie.modules.system.domain.req.IdCardReqDTO;
import me.zhengjie.modules.system.domain.rsp.BandCardRspDTO;
import me.zhengjie.modules.system.domain.rsp.BankCardSubBranchInfoRspDTO;
import me.zhengjie.modules.system.domain.rsp.IdCardRspDTO;
import me.zhengjie.modules.system.service.OcrService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
@Api(tags = "ocr校验")
@RequestMapping("/api/ocr")
public class OcrController {

    private final OcrService ocrService;

    @Log("根据身份证照片查询身份证信息")
    @ApiOperation("根据身份证照片查询身份证信息")
    @AnonymousPostMapping(value = "/readIdCard")
    public ResponseEntity<IdCardRspDTO> readIdCard(@RequestBody IdCardReqDTO idCardReqDTO) {
        return new ResponseEntity<>(ocrService.readIdCard(idCardReqDTO), HttpStatus.OK);
    }

    @Log("根据银行卡照片查询卡号")
    @ApiOperation("根据银行卡照片查询卡号")
    @AnonymousPostMapping(value = "/readBankCard")
    public ResponseEntity<BandCardRspDTO> readBankCard(@RequestBody BankCardReqDTO bankCardReqDTO) {
        return new ResponseEntity<>(ocrService.readBankCard(bankCardReqDTO), HttpStatus.OK);
    }

    @Log("根据银行卡号查询支行信息")
    @ApiOperation("根据银行卡号查询支行信息")
    @AnonymousPostMapping(value = "/readBankCardSubBranch")
    public ResponseEntity<BankCardSubBranchInfoRspDTO> readBankCardSubBranch(@RequestBody BankCardSubBranchReqDTO reqDTO) {
        return new ResponseEntity<>(ocrService.readBankCardSubBranch(reqDTO), HttpStatus.OK);
    }


}
